<template>
  <popup-select
    :value="value"
    @update:value="(v) => emit('update:value', v)"
    :columns="[
      { title: () => t('姓名'), dataIndex: 'personName' },
      { title: () => t('性别'), dataIndex: 'gender' },
    ]"
    hide-btn-text
    :placeholder="t('请选择人员')"
    :width="600"
    :field-names="{ label: 'personName', value: 'personId' }"
    :query-by-id="(queryById as PopupSelectProps['queryById'])"
    :query-by-page="queryByPage"
    :size="size"
    :multiple="multiple"
    @bring="(v, r) => emit('bring', v, r)"
  >
    <template #search-form="{ params }">
      <a-col :span="16">
        <a-form-item :label="t('用户名/名称')">
          <a-input
            v-model:value="params.keyword"
            :placeholder="t('请输入用户名/名称')"
            allow-clear
          ></a-input>
        </a-form-item>
      </a-col>
    </template>
  </popup-select>
</template>
<script lang="ts" setup>
import { useI18n } from "vue-i18n";
import { queryById, queryByPage } from "@/api/system/person";
import type { SizeType } from "@/typing";
import type { PopupSelectProps } from "../popup-select/typing";
import PopupSelect from "@/components/popup-select/index.vue";
interface Props {
  /**绑定值 */
  value: string | string[];
  /**多选 */
  multiple?: boolean;
  /**控件大小 */
  size?: SizeType;
}
withDefaults(defineProps<Props>(), {
  multiple: false,
});
const emit = defineEmits(["update:value", "bring"]);
const { t } = useI18n();
</script>
